package cn.smxy.admin.controller;

import cn.smxy.admin.param.PlantPageAdminParam;
import cn.smxy.admin.service.PlantService;
import cn.smxy.param.PlantAddParam;
import cn.smxy.param.PlantRemoveParam;
import cn.smxy.pojo.Plant;
import cn.smxy.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/works")
public class PlantController {

    @Autowired
    private PlantService plantService;

    /**
     * 单种群多科属分页展示接口
     *
     * @param plantPageAdminParam 分页参数
     * @return
     */
    @GetMapping("/page")
    public R page(PlantPageAdminParam plantPageAdminParam) {
        return plantService.page(plantPageAdminParam);
    }

    /**
     * 上传植物作品接口
     *
     * @param plantAddParam 植物实体类，包括多张图片属性
     * @return
     */
    @PostMapping("/add")
    public R add(PlantAddParam plantAddParam){
        return plantService.add(plantAddParam);
    }

    /**
     * 删除植物作品接口
     *
     * @param plantRemoveParam 用户id和植物id
     * @return
     */
    @PostMapping("/remove")
    public R remove(PlantRemoveParam plantRemoveParam){
        return plantService.remove(plantRemoveParam);
    }

    /**
     * 修改植物作品接口
     *
     * @param plantAddParam 植物实体类
     * @return
     */
    @PostMapping("/update")
    public R update(PlantAddParam plantAddParam){
        return plantService.update(plantAddParam);
    }
}
